//
//  ZYCProtalCalendarStatisticsCell.m
//  ZDSC
//
//  Created by ZDTX on 2021/7/21.
//

#import "ZYCProtalCalendarStatisticsCell.h"
#import "ZYCCalendarStatisticsModel.h"
#import <UIImageView+WebCache.h>
#import "ZYCUserInfoModel.h"
#import "ZYCCalendarStatisticsModel.h"

@interface ZYCProtalCalendarStatisticsCell ()
@property (nonatomic, strong) UIImageView *iconView;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@end
@implementation ZYCProtalCalendarStatisticsCell

- (void)setTModel:(ZYCCalendarStatisticsModel *)tModel{
    _tModel = tModel;
    _iconView.image = [UIImage imageNamed:@"headerPlace"];
    _titleLabel.text = tModel.userName;
    _timeLabel.text = tModel.checkTime;
}
- (void)setSModel:(ZYCBindStudentModel *)sModel{
    _sModel = sModel;
    _titleLabel.text = sModel.name;
    _iconView.image = [UIImage imageNamed:@"headerPlace"];
}



- (void)setModel:(ZYCCalendarStatisticsModel *)model{
    _model = model;
    _titleLabel.text = model.userName;
    _timeLabel.text = model.checkTime;
    [_iconView sd_setImageWithURL:[NSURL URLWithString:_model.avatar] placeholderImage:[UIImage imageNamed:@"headerPlace"]];
}

- (void)setIsRead:(BOOL)isRead{
    _isRead = isRead;
    _timeLabel.hidden = !isRead;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.iconView];
        [self.contentView addSubview:self.titleLabel];
        [self.contentView addSubview:self.timeLabel];
    
        [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView).offset(15.0f);
            make.centerY.equalTo(self.contentView);
            make.size.mas_equalTo(CGSizeMake(40.0f, 40.0f));
        }];

        [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.iconView.mas_right).offset(10.0f);
            make.centerY.equalTo(self.iconView);
        }];

        [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView).offset(-20.0f);
            make.centerY.equalTo(self.contentView);
        }];
        
    }
    return self;
}
- (UIImageView *)iconView {
    if (!_iconView) {
        _iconView = [[UIImageView alloc] init];
//        _iconView.backgroundColor = [UIColor grayColor];
        _iconView.layer.cornerRadius = 20.0f;
        _iconView.layer.masksToBounds = YES;
    }
    return _iconView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Regular", 18) titleColor:HEX_RGB(kTitleThemeColor) textAlignment:ZZTextAlignmentLeft];
    }
    return _titleLabel;
}

- (UILabel *)timeLabel {
    if (!_timeLabel) {
        _timeLabel = [UILabel LabelWithFont:kCustomFont(@"PingFangSC-Light", 14) titleColor:HEX_RGB(@"#888888") textAlignment:ZZTextAlignmentRight];
    }
    return _timeLabel;
}



@end
